package state;

import java.util.Hashtable;

import javax.microedition.midlet.MIDlet;

import state.bean.Rect;

public class GameGlobal {
  public static void init(MIDlet miDlet) {
    // Xác định kích cỡ màn hình hiện tại là màn hình ngang hay màn hình dọc
    systemCanvas = new SystemCanvas();
    systemCanvas.setMidlet(miDlet);
    if (systemCanvas.getWidth() >= 320) {
      GameConstants.IS_240x320_SCREEN = false;
      GameConstants.SCREEN_WIDTH = 320;
      GameConstants.SCREEN_HEIGHT = 240;
    }
    GameConstants.DEVICE_SCREEN = new Rect(0, 0, GameConstants.SCREEN_WIDTH, GameConstants.SCREEN_HEIGHT);
    
    // Load resource for default category 
    resourceCategory = new Hashtable();
    Hashtable defaultResourceMaster = ResourceRms.loadMasterRecord(GameConstants.DEFAULT_RESOURCE_CATEGORY);
    if (defaultResourceMaster != null) {
      resourceCategory.put(GameConstants.DEFAULT_RESOURCE_CATEGORY, defaultResourceMaster);
    }
  }
  
	public static SystemCanvas systemCanvas;
	public static Alert alert;
	
	// Các biến để download resource
	public static int totalDownloadResource = Integer.MAX_VALUE;
	public static int downloadedCount = 0;
	
	public static Hashtable resourceCategory;
	
	public static void nextState(GameForm state, Hashtable table) {
		systemCanvas.nextState(state, table);
	}
	
	public static void nextState(GameForm state, Hashtable table, int transformType) {
		systemCanvas.nextState(state, table, transformType);
	}
	
	public static MIDlet getMidlet() {
	  return systemCanvas.getMidlet();
	}
	
	public static void setMidlet(MIDlet midlet) {
	  systemCanvas.setMidlet(midlet);
	}
	
	public static void setTimerDelay(int delay) {
	  systemCanvas.setTimerDelay(delay);
	}
}
